#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Introduce :
@File      : demo1.py
@Time      : 2021/11/9 19:44
@Author    : toby
"""


import numpy as np
import pandas as pd

p1 = pd.Series([1,2,34,5])        #传入数组
print(p1)
a = np.arange(0,3)
print(a)
myvar = pd.Series(a,index=['x','u','x'])    #指定index
print(myvar)

#a 数组  ，rows  行 索引  columns 列索引
data = [['Google',10],['Runoob',12],['Wiki',13]]

df = pd.DataFrame(data,columns=['Site','Age'],dtype=float)

print(df)

data2 ={'site':["google","runoob","wike"],"age":[10,12,13]}
df=pd.DataFrame(data2,index=[4,6,0])
print(df)
# Pandas 可以使用 loc 属性返回指定索引对应到某一行：
print(df.loc[[4,0]])

# 三个字段 name, site, age
nme = ["Google", "Runoob", "Taobao", "Wiki"]
st = ["www.google.com", "www.runoob.com", "www.taobao.com", "www.wikipedia.org"]
ag = [90, 40, 80, 98]

# 字典
dict = {'name': nme, 'site': st, 'age': ag}

df = pd.DataFrame(dict)

# 保存 dataframe
df.to_csv('site.csv')








